﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xrm.Solutions.FrameworkSample.Common;
using Moq;

namespace Xrm.Solutions.FrameworkSample.UnitTests
{
    [TestClass]
    public class TestCreditLimitMoq
    {
        [TestMethod]
        public void TestCreditLimitUsingMoq()
        {
            Mock<IIdentityCheckService> identityServiceMock = new Mock<IIdentityCheckService>();

            identityServiceMock.Setup(service => service.RunCheck("Wael",
                                                    "Hamze",
                                                    new DateTime(1990, 01, 01),
                                                    "10 South Colonnade")
                            ).Returns(99);

            CreditLimitServiceDI creditLimitService = new CreditLimitServiceDI(identityServiceMock.Object);

            int creditLimit = creditLimitService.IncreaseLimit("Wael",
                                                    "Hamze",
                                                    new DateTime(1990, 01, 01),
                                                    "10 South Colonnade",
                                                    500,
                                                    1000);

            Assert.AreEqual(creditLimit, 750);
        }
    }
}
